import {createRouter, createWebHashHistory} from "vue-router";

// import Home from './components/News.vue'
// import Mine from './components/Mine.vue'
// import News from './components/News.vue'


const Home = () =>
    import ('./components/Home.vue')

const Mine = () =>
    import ('./components/Mine.vue')

const News = () =>
    import ('./components/News.vue')
const MineMsg = () =>
    import ('./components/MineMsg.vue')
const MineOrder = () =>
    import ('./components/MineOrder.vue')
const Circle = () =>
    import ('./components/Circle.vue')

const routes = [
    {path: '/news', component: Home, meta:{title:'首页'}},
    {
        path: '/mine', component: Mine,  meta:{title:'个人中心'},children: [
            {path: 'mine-msg', component: MineMsg, meta:{title:'我的消息'}},
            {path: 'mine-order', component: MineOrder, meta:{title:'我的订单'}}
        ]
    },
    {path: '/news/:id', component: News, meta:{title:'新闻详情'}},
    {path: '/circle', component: Circle, meta:{title:'圈子'}},
    {path: '/', redirect: '/news'},
]

const router = createRouter({
    history: createWebHashHistory(),
    routes,
    linkActiveClass: "current"
})
router.beforeEach((to, from, next) => {
    console.log("from", from)
    console.log("to", to.meta)
    console.log("next", next)
    document.title = to.meta.title
    next();


})
export default router;